from django.db import models

# Create your models here.
from user.models import Staff


class Approve(models.Model):
    appr_id = models.CharField(primary_key=True, max_length=32, verbose_name='')
    num = models.CharField(max_length=10, blank=True, null=True)
    staff = models.ForeignKey(Staff, on_delete=models.DO_NOTHING, blank=True, null=True)
    start_time = models.DateTimeField(blank=True, null=True)
    status = models.CharField(max_length=20, blank=True, null=True)
    content = models.CharField(max_length=200, blank=True, null=True)
    finish_time = models.DateTimeField(blank=True, null=True)
    appr_kind = models.CharField(max_length=20, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'approve'


class ApprFlow(models.Model):
    flow_id = models.CharField(primary_key=True, max_length=32)
    appr = models.ForeignKey(Approve, on_delete=models.DO_NOTHING, db_column='appr_id', blank=True, null=True)
    staff = models.ForeignKey(Staff,on_delete=models.DO_NOTHING,db_column='staff', blank=True, null=True)
    idea = models.CharField(max_length=10, blank=True, null=True, verbose_name='审批意见')
    appr_time = models.DateTimeField(blank=True, null=True, verbose_name='审批时间')
    content = models.TextField(blank=True, null=True, verbose_name='审批备注')
    status = models.CharField(max_length=20, blank=True, null=True, verbose_name='审批状态')

    class Meta:
        managed = False
        db_table = 'appr_flow'


class ApprHistory(models.Model):
    apprhis_id = models.CharField(primary_key=True, max_length=32)
    num = models.CharField(max_length=10, blank=True, null=True, verbose_name='审批编号')
    staff = models.ForeignKey(Staff,on_delete=models.DO_NOTHING, blank=True, null=True, verbose_name='提交员工姓名')
    start_time = models.DateTimeField(blank=True, null=True, verbose_name='开始时间')
    finish_time = models.DateTimeField(blank=True, null=True, verbose_name='完成时间')
    status = models.CharField(max_length=20, blank=True, null=True, verbose_name='状态')
    appr_kind = models.CharField(max_length=20, blank=True, null=True, verbose_name='审批类型')
    appr_name = models.CharField(max_length=32, blank=True, null=True, verbose_name='审批人姓名')
    appr_idea = models.CharField(max_length=20, blank=True, null=True, verbose_name='审批意见')
    appr_time = models.DateTimeField(blank=True, null=True, verbose_name='审批时间')
    start_cont = models.TextField(blank=True, null=True, verbose_name='审批内容')
    content = models.TextField(blank=True, null=True, verbose_name='备注')

    class Meta:
        managed = False
        db_table = 'appr_history'


class ApprRank(models.Model):
    rank_id = models.CharField(primary_key=True, max_length=32)
    appr = models.ForeignKey(Approve, on_delete=models.DO_NOTHING, blank=True, null=True)
    rank = models.IntegerField(blank=True, null=True, verbose_name='审批顺序')
    staff = models.ForeignKey(Staff, on_delete=models.DO_NOTHING, blank=True, null=True, verbose_name='审批人')
    status = models.CharField(max_length=10, blank=True, null=True, verbose_name='审批状态')

    class Meta:
        managed = False
        db_table = 'appr_rank'


